{% extends 'base.html' %}
{% block title %}首页{% endblock %}
{% block head %}
    <link rel="stylesheet" href="{{ url_for('static', filename='css/index.css') }}">
{% endblock %}
{% block main %}
    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">用户权限管理</div>

        <!-- Table -->
        <table class="table">
            <tr>
                <th>用户名</th>
                <th>手机号</th>
                <th>当前角色</th>
                <th>升降级操作</th>
            </tr>
            {% for user in users.items %}
                <tr>
                    <td>{{ user.uname }}</td>
                    <td>{{ user.tel }}</td>
                    <td>{{ user.role_id }}</td>
                    <td>
                        <form action="{{ url_for('level_up') }}" method="get">
                            <button type="submit" class="btn btn-primary" name="upgrade" value="{{ user.uname }}">升级
                            </button>
                        </form>
                    </td>
                    <td>
                        <form action="{{ url_for('level_down') }}" method="get">
                            <button type="submit" class="btn btn-primary" name="downgrade" value="{{ user.uname }}">降级
                            </button>
                        </form>
                    </td>
                </tr>
            {% endfor %}
        </table>
        <nav aria-label="Page navigation" style="text-align: center">
            <ul class="pagination">
                <li>
                    {% if users.has_prev %}
                        <a href="{{ url_for('right_manage', page = users.prev_num) }}" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    {% else %}
                        <span aria-hidden="true">&laquo;</span>
                    {% endif %}
                </li>
                <li><a href="{{ url_for('right_manage', page = 1) }}">1</a></li>
                <li><a href="{{ url_for('right_manage', page = 2) }}">2</a></li>
                <li><a href="{{ url_for('right_manage', page = 3) }}">3</a></li>
                <li>
                    {% if users.has_next %}
                        <a href="{{ url_for('right_manage', page = users.next_num) }}" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    {% else %}
                        <span aria-hidden="true">&raquo;</span>
                    {% endif %}
                </li>
            </ul>
        </nav>
    </div>
{% endblock %}